package com.threegroup.admin.controller;

import com.threegroup.admin.annotation.AuthorityVerify.AuthorityVerify;
import com.threegroup.common.dto.OrdersPageDTO;
import com.threegroup.admin.service.OrdersService;
import com.threegroup.common.dto.OrdersDTO;
import com.threegroup.common.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class OrdersController {
    @Resource
    private OrdersService ordersService;

    //添加订单
    @AuthorityVerify("takeout:orders:save")
    @PostMapping("takeout/orders")
    public Result addOrder(@RequestBody OrdersDTO ordersDTO) {
        Result result = ordersService.addOrders(ordersDTO);
        return result;
    }

    //修改订单
    @AuthorityVerify("takeout:orders:update")
    @PutMapping("takeout/orders")
    public Result updeteOrder(@RequestBody OrdersDTO ordersDTO) {
        Result result = ordersService.updeteOrders(ordersDTO);
        return result;
    }

    //删除订单
    @AuthorityVerify("takeout:orders:delete")
    @DeleteMapping("takeout/orders")
    public Result deleteOrderDetail(@RequestBody Long[] ids) {
        Result result = ordersService.deleteOrders(ids);
        return result;
    }

    //查询订单信息
    @AuthorityVerify("takeout:orders:info")
    @GetMapping("takeout/orders/{id}")
    public Result selectOrders(@PathVariable("id") Long id){
        Result result = ordersService.selectOrders(id);
        return result;
    }

    //分页查询订单
    @AuthorityVerify("takeout:orders:page")
    @GetMapping("takeout/orders/page")
    public Result selectOrderDetailList(OrdersPageDTO ordersPageDTO){
        Result result = ordersService.selectOrderDetailList(ordersPageDTO);
        return result;
    }

}
